package com.itlong.cloud.property;

import com.itlong.cloud.paymenthub.IProjectAllowedCashWithdrawalStatisticsClient;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

/**
 * <desc>
 *      统计项目可提现余额定时任务
 * </desc>
 *
 * @createDate 2018/09/26
 */
@EnableScheduling // 启用定时任务
@RestController
public class ProjectAllowedCashWithdrawalStatisticsTimedTask {

    private static Logger LOG = LoggerFactory.getLogger(ProjectAllowedCashWithdrawalStatisticsTimedTask.class);

    @Autowired
    private IProjectAllowedCashWithdrawalStatisticsClient iProjectAllowedCashWithdrawalStatisticsClient;

    /**
     * <desc>
     *      定时统计项目可提现余额，只统计前一天(来自于微信转账)
     * </desc>
     *
     * @author wangzhi
     * @createDate 2018/09/26
     */
//    @Scheduled(cron = "0 * * * * ?") // 每分钟执行一次（用于测试）
    @Scheduled(cron = "0 30 0 * * ?") // 每天凌晨0点半执行
    public void statisticsAllowedCashWithdrawal() throws Exception{
        try {
//            LOG.info("【定时任务】定时统计项目可提现余额开始");
            iProjectAllowedCashWithdrawalStatisticsClient.statisticsAllowedCashWithdrawal();
//            LOG.info("【定时任务】定时统计项目可提现余额成功");
        } catch (Exception e){
            LOG.error("【定时任务】定时统计项目可提现余额失败");
            throw e;
        }
    }

}
